/*
	YoghurtGum - 2D Game Engine

	Copyright 2009-2011 Quinten Lansu
	
	Licensed under the Apache License, Version 2.0 (the "License"); you may not 
	use this file except in compliance with the License. You may obtain a copy 
	of the License at 
		
		http://www.apache.org/licenses/LICENSE-2.0 
		
	Unless required by applicable law or agreed to in writing, software 
	distributed under the License is distributed on an "AS IS" BASIS, WITHOUT 
	WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the 
	License for the specific language governing permissions and limitations 
	under the License. 
*/

#ifndef _YGARRAY_H_
#define _YGARRAY_H_

#include "YGSettings.h"

namespace YoghurtGum
{

	template<class Data> class Array
	{

	public:

		Array(uint32 a_Total)
		{
			m_Data = new Data*[m_Total];
			m_Current = 0;
			m_Total = a_Total;
		}
		~Array();

		bool Push(Data* a_Data)
		{
			// TODO: expand array
			if (m_Current + 1 == m_Total) { return false; }
			m_Data[m_Current++] = a_Data;
			return true;
		}

		Data* Pop()
		{
			return m_Data[m_Current--];
		}

		uint32 GetSize() { return m_Current; }
		uint32 GetMaxSize() { return m_Total; }

		Data* operator [] (uint32 a_Index)
		{
			if (a_Index > m_Current) { return NULL; }
			return m_Data[a_Index];
		}

	private:

		Data** m_Data;
		uint32 m_Current, m_Total;

	}; // class Array

}; // namespace YoghurtGum

#endif